package com.shelpe.services.algorithm.client;

import java.util.Date;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;

@FeignClient(name="${feign.sustainerserver.name}", url="${feign.sustainerserver.url}", fallback=SustainerClientFallback.class)
public interface SustainerClient {

	@RequestMapping(path = "/sustainerservice/sustainers", method = RequestMethod.POST,  consumes="application/json;charset=UTF-8")
	SustainerDto createSustainer(@RequestBody SustainerDto dto);
	
	@RequestMapping(path = "/sustainerservice/sustainers", method = RequestMethod.DELETE,  consumes="application/json;charset=UTF-8")
	SustainerDto deleteSustainer(@RequestParam("callee_id") String calleeID, @RequestParam("callee_type")String type);
	
	
	@Data
	public static class SustainerDto{
		@JsonProperty("callee_type")
		private String type;
		@JsonProperty("callee_id")
		private String calleeID;
		
		@JsonProperty("service_id")
		private String serviceID;
		private String path;
		
		@JsonProperty("next_jump_point")
		@JsonFormat(shape=Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
		private Date nextJumpPoint;
	}
	
}
